package com.dnjn.happiness.emo.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dnjn.happiness.common.config.DateTimeFormatHolder;
import com.dnjn.happiness.emo.domain.vo.AvgScoreChangeBean;
import com.dnjn.happiness.emo.mapper.EmoAvgScoreDailyMapper;
import com.dnjn.happiness.emo.service.IEmoAvgScoreDailyService;
import com.dnjn.happiness.emo.api.domain.EmoAvgScoreDaily;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * 快乐值日均Service业务层处理
 *
 * @author happiness
 * @date 2024-02-27
 */
@Service
public class EmoAvgScoreDailyServiceImpl extends ServiceImpl<EmoAvgScoreDailyMapper, EmoAvgScoreDaily> implements IEmoAvgScoreDailyService {

    @Override
    public BigDecimal getCurrWeekHappinessScore(Long userId, String weekOfYear) {
        return baseMapper.getCurrWeekHappinessScore(userId, weekOfYear);
    }

    @Override
    public EmoAvgScoreDaily selectDailyScoreAvgByUserId(Long userId) {
        return baseMapper.selectDailyScoreAvgByUserId(userId);
    }

    @Override
    public List<AvgScoreChangeBean> getScoreChangeByUserId(Long userId) {
        LocalDate endTime = LocalDate.now();
        LocalDate startTime = LocalDate.now().minusDays(30);
        return baseMapper.getScoreChangeByUserId(userId, startTime, endTime);
    }

}
